From ba4c37ec3df9ddbfd06864f72b3c12cd1bd83fda Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 4 Apr 2023 15:11:42 -0700 Subject: rate refactoring --- src/routes/(app)/[username]/invoice/[hash]/+layout.server.js | 6 ++++-- src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src/routes/(app)/[username]/invoice') diff --git a/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js b/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js index 7cf87e14..04d413bb 100644 --- a/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js +++ b/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js @@ -12,10 +12,12 @@ export async function load({ depends, params, url, parent }) { if (user && invoice.uid !== user.id && !url.pathname.includes('tip')) throw redirect(307, `/send/invoice/${hash}`); - let { amount, received } = invoice; + let { amount, pending, received } = invoice; amount = parseInt(amount); - let paid = (!amount && received) || (amount > 0 && received >= amount); + console.log("PENDING", pending) + + let paid = (!amount && received) || (amount > 0 && (pending >= amount || received >= amount)); if (paid && !url.pathname.endsWith('paid')) throw redirect(307, `/${params.username}/invoice/${hash}/paid`); diff --git a/src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte b/src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte index 4d7aae51..c9619cee 100644 --- a/src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte +++ b/src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte @@ -21,7 +21,7 @@ {#if received}

{$t('invoice.paymentSuccessful')}

- {f(fiat(received, rate), currency)} + {f(fiat(received - tip, rate), currency)} {#if tip} + {f(fiat(tip, rate), currency)} @@ -29,7 +29,7 @@ {/if}

- ⚡️{s(received)} + ⚡️{s(received - tip)} {#if tip} @@ -42,13 +42,13 @@ {#if pending}

Payment detected

- {f(fiat(pending, rate), currency)} + {f(fiat(pending - tip, rate), currency)} {#if tip} + {f(fiat(tip, rate), currency)} {/if}

- ⚡️{s(pending)} + ⚡️{s(pending - tip)} {#if tip} + ⚡️{s(tip)} -- cgit v1.2.3